package leetcode_day._2022._202201._0110;

/**
 * @author yzh
 * @version 1.0
 * @date 2022/1/1 22:25
 * 将一维数组转变成二维数组
 * 算法：模拟
 */
public class _01_2022 {

    public int[][] construct2DArray(int[] original, int m, int n) {
        if (original.length != m * n) return new int[0][0];
        int[][] ans = new int[m][n];
        for (int i = 0, idx = 0; i < m; i++) for (int j = 0; j < n; j++) ans[i][j] = original[idx++];
        return ans;
    }

}
